package com.kly.msg.controller;

import com.alibaba.fastjson.JSONObject;
import com.fqgj.base.services.redis.RedisClient;
import com.fqgj.common.api.Response;
import com.kly.dto.PushSendRequest;
import com.kly.dto.SmsConfigRequestDTO;
import com.kly.msg.constant.ApiRedisKeys;
import com.kly.service.PushMsgService;
import com.kly.service.SMSService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 测试接口不对外暴露
 */
@RestController
@RequestMapping("api/msg")
@Slf4j
public class SMSController {

    @Resource
    PushMsgService pushMsgService;

    @Resource
    SMSService smsService;

    @ResponseBody
    @RequestMapping(value = "/pushMsg")
    public Response test(@RequestBody PushSendRequest pushSendRequest){
        log.info("接收到数据：{}", JSONObject.toJSONString(pushSendRequest));
        final Response<Boolean> pushResult = pushMsgService.singlePush(pushSendRequest);
        return Response.ok(pushResult);
    }


    @ResponseBody
    @PostMapping(value = "/updateSmsConfig")
    public Response updateSmsConfig(@RequestBody SmsConfigRequestDTO smsConfigRequestDTO){

        return Response.ok(smsService.updateSmsConfig(smsConfigRequestDTO));
    }

}
